<?php

namespace app\common\model;

use think\Model;


class SaleStatistics extends Model
{

    

    

    // 表名
    protected $name = 'sale_statistics';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
		'status_text'
    ];
    
	const STATUS_WAIT = 0;
	const STATUS_DONE = 1;
    
	public static $statusList = [
		self::STATUS_DONE => '已结算',
		self::STATUS_WAIT => '待结算'
	];

	public function getStatusTextAttr($value, $data) {
		$value = $value ? : $data['status'];
		$list = self::$statusList;
		return $list[$value] ?? '';
	}



	public function agent() {
		return $this->belongsTo('agentShop', 'agent_id', 'id', '', 'left')->setEagerlyType(0);
	}

}
